// pages/share/list/list.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		name: [0],
		value:'',
		value1:''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		wx.request({
			url: getApp().globalData.http + 'action=selectServerType&id=' + options.id,
			success: (e) => {
				console.log(e)
				this.setData({
					data: e.data.data,
				})
			}
		})
	},
	onShow() {
		    let pages = getCurrentPages();
		    let prevpage = pages[pages.length - 2];
		    console.log(pages)
		if (this.data.value != this.data.value1&&this.data.value !='') {
			let a = this.data.list
			let n=this.data.name
			n=n.join()
			a = a.join()
			this.setData({
				value1:this.data.value
			})
			wx.navigateTo({
				url: '../li/li?type=' + a + '&id=' + this.data.value[0] + '&map=' + this.data.value[2] + '&name=' + n
			})
		}
	},
	goin() {
		if (this.data.list != undefined && this.data.list != '') {
			wx.navigateTo({
				url: '../../city/city'
			})
		} else {
			wx.showToast({
				icon: 'none',
				title: '请选择门店'
			})
		}
	},
	id(e) {
		var item = e.detail.value //选中的数组
		var id = []; //选中的ID
		var name = []; //选中的NAME

		//循环选中的数组，取出对应的数据进行数组拼接
		for (var i = 0; i < item.length; i++) {
			var row = item[i].split(",") //将数组进行分割
			id = id.concat(row[0]) //数组下表的第一个为id
			name = name.concat(row[1]) //数组下表的第二个为name
		}
		console.log(id)
		console.log(name)
		this.setData({
			name:name,
			list:id,
		})
	},
})
